package com.settlement.system.model.entity.common;

/**
 * 分页
 * @author user
 */
public class SinglePage {

    /**
     * 开始的行数
     */
    private long startRowNum = 0;

    /**
     * 一页的大小
     */
    private int pageSize = 10;

    /**
     * 开始的页码
     */
    private int pageNo = 1;

    /**
     * 无参构造函数
     */
    public SinglePage() {

    }

    public SinglePage(BasePager pager){
        this.pageNo = pager.pageNum == null ? 1 :  pager.pageNum;
        this.pageSize = pager.pageSize == null ? 10 :  pager.pageSize;
        this.startRowNum = (pageNo - 1) * pageSize;
    }

    /**
     * 第几页
     * @param pageNo
     * @param pageSize
     */
    public SinglePage(int pageNo, int pageSize) {
        this.pageNo = pageNo;
        this.pageSize = pageSize;
        this.startRowNum = (pageNo - 1) * pageSize;
    }

    public long getStartRowNum() {
        return startRowNum;
    }

    public void setStartRowNum(long startRowNum) {
        this.startRowNum = startRowNum;
    }

    public int getPageSize() {
        return pageSize;
    }

    public void setPageSize(int pageSize) {
        this.pageSize = pageSize;
        this.startRowNum = (pageNo - 1) * pageSize;
    }

    public int getPageNo() {
        return pageNo;
    }

    public void setPageNo(int pageNo) {
        this.pageNo = pageNo;
        this.startRowNum = (pageNo - 1) * pageSize;
    }
}
